package com.hireceivecard.config;
import com.hireceivecard.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
 *
 * @Description: 统一异常处理
 * @Author: 欧阳
 * @Date: 2024/3/24 0:17
 * @Email: 2742866928@qq.com
 */
@RestControllerAdvice
public class AppExceptionHandler {

    @ExceptionHandler
    public Result doException(Exception e) {
       if (e instanceof AppException){
           AppException appException=(AppException) e;
           appException.printStackTrace();
           return new Result(appException.getMessage(), null, appException.getErrcode());
       }
       e.printStackTrace();
       return new Result("系统异常请稍后再试！",e.getMessage(),500);
    }
}
